#ifndef __SIMULATE_I2C_H__
#define __SIMULATE_I2C_H__

#include "bsp_board.h"

typedef enum{
  NO_ERROR       = 0x00, // no error
  ACK_ERROR      = 0x01, // no acknowledgment error
  CHECKSUM_ERROR = 0x02, // checksum mismatch error
  TIMEOUT_ERROR  = 0x04, // timeout error
  PARM_ERROR     = 0x80, // parameter out of range error
}etError;
  
typedef enum en_result
{
    Ok                          = 0u,  ///< No error
    Error                       = 1u,  ///< Non-specific error code
    ErrorAddressAlignment       = 2u,  ///< Address alignment does not match
    ErrorAccessRights           = 3u,  ///< Wrong mode (e.g. user/system) mode is set
    ErrorInvalidParameter       = 4u,  ///< Provided parameter is not valid
    ErrorOperationInProgress    = 5u,  ///< A conflicting or requested operation is still in progress
    ErrorInvalidMode            = 6u,  ///< Operation not allowed in current mode
    ErrorUninitialized          = 7u,  ///< Module (or part of it) was not initialized properly
    ErrorBufferFull             = 8u,  ///< Circular buffer can not be written because the buffer is full
    ErrorTimeout                = 9u,  ///< Time Out error occurred (e.g. I2C arbitration lost, Flash time-out, etc.)
    ErrorNotReady               = 10u, ///< A requested final state is not reached
    OperationInProgress         = 11u  ///< Indicator for operation in progress
} en_result_t;

typedef enum{
  ACK  = 0,
  NACK = 1,
}etI2cAck;

 #ifdef __MM_SIMULATE_I2C__
void sI2C_SCL_Configure(uint8_t Direction);
void sI2C_SCL_Write(uint8_t Level);
void sI2C_SDA_Configure(uint8_t Direction);
void sI2C_SDA_Write(uint8_t Level);
uint8_t sI2C_SDA_Read(void);
void sI2C_GenerateStart(void);
void sI2C_GenerateStop(void);
void sI2C_PutACK(uint8_t Type);
uint8_t sI2C_GetACK(void);
uint8_t sI2C_ReadByte(void);
void sI2C_WriteByte(uint8_t Data);
void I2C_Configure(void);
uint8_t I2C_TxData_Polling(uint8_t addr,uint8_t Reg_Addr, uint8_t *Buffer, uint8_t Length);
uint8_t I2C_MasterWrite_16Reg(uint8_t addr,uint16_t Reg_Addr, uint8_t *Buffer, uint8_t Length);
uint8_t I2C_read(uint8_t addr,uint8_t Reg_Addr, uint8_t *Buffer, uint16_t Length);
uint8_t I2C_read_16Reg(uint8_t addr,uint16_t Reg_Addr, uint8_t *Buffer, uint16_t Length);


#else
void SDA_HIGH(void);
void SCL_HIGH(void);
void SDA_LOW(void);
void SCL_LOW(void);
void SDA_OUT(void);
void SCL_OUT(void);
bool SDA_GET(void);
void SCL_IN(void);	
void SDA_IN(void); 																			
void I2c_StartCondition(void);
void I2c_StopCondition(void);
en_result_t I2c_ReadByte(uint8_t *rxByte, etI2cAck ack, uint8_t timeout);
en_result_t I2C_WriteByte(uint8_t u8Data);
en_result_t I2C_MasterWrite(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t num);
en_result_t I2C_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t num);
en_result_t I2C_MasterWrite_16Reg(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t num);
en_result_t I2C_read_16Reg(uint8_t addr, uint16_t reg, uint8_t *buf, uint8_t num);

void sda_control_10(void);
void scl_control_10(void);
void scl_sda_change(void);
#endif

#endif

